﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using STDTO.DataTransferObjects.Unit.Tests.Interfaces;
using STDTO.DataTransferObjects.Base;
using System.Runtime.Serialization;
using STDTO.DataTransferObjects.Interfaces;
using Microsoft.Practices.Unity;

namespace STDTO.DataTransferObjects.Unit.Tests.DTOs
{
    [DataContract]
    public class ObjectContainsCircularReferenceDto : UnitySelfTrackingDataTransferObjectBase<IObjectContainsCircularReference>, IObjectContainsCircularReference
    {
        public ObjectContainsCircularReferenceDto(IUnityContainer unityContainer) : base(unityContainer) { }
        #region ISimpleObject Members
        [DataMember]
        private int _Id;
        [DataMember]
        private IObjectContainsCircularReference _ObjectContainsCircularReference;
   

        public int Id
        {
            get
            {
                return _Id;
            }
            set
            {
                Set("Id", ref _Id, value);
            }
        }


        public IObjectContainsCircularReference InnerObjectContainsCircularReference
        {
            get
            {
                return _ObjectContainsCircularReference;
            }
            set
            {
                Set("ObjectContainsCircularReference", ref _ObjectContainsCircularReference, value); ;
            }
        }

        #endregion

        protected override void SpecificPopulate(IObjectContainsCircularReference entity, IDataTrasferObjectToEntityMapper dataTrasferObjectToEntityMapper)
        {
            _Id = entity.Id;
            _ObjectContainsCircularReference = CreateDtoInner<IObjectContainsCircularReference>(entity.InnerObjectContainsCircularReference, dataTrasferObjectToEntityMapper);
            
        }

        protected override void SpecificGetValue(IObjectContainsCircularReference entity, bool getOriginalValue, IDataTrasferObjectToEntityMapper dataTrasferObjectToEntityMapper)
        {
            entity.Id = RetrievePropertyValue<int>("Id", getOriginalValue);
            entity.InnerObjectContainsCircularReference = ((ISelfTrackingDataTransferObjectEx<IObjectContainsCircularReference>)InnerObjectContainsCircularReference).Clone(getOriginalValue, dataTrasferObjectToEntityMapper);
            
        }

        protected override void SpecificApplyChanges(IObjectContainsCircularReference entity, IDataTrasferObjectToEntityMapper dataTrasferObjectToEntityMapper)
        {
            ((ISelfTrackingDataTransferObjectEx<IObjectContainsCircularReference>)InnerObjectContainsCircularReference).ApplyChanges(entity.InnerObjectContainsCircularReference, dataTrasferObjectToEntityMapper);
        }	 
    
    }
}
